package peer.assist.message;

import java.net.DatagramPacket;

import peer.Message;
import peer.tools.ByteIntSwitch;
import peer.tools.ByteShortSwitch;

public class ReversePingMessage1 extends Message{
	public short sType=peer.tools.MessageType.sType_ReversePingMessage1;
	byte[] dpData;
	int assistSessionId;
	int pingSessionId;
	public ReversePingMessage1(int pingSessionId,int assistSessionId){
		dpData=new byte[12];
		ByteShortSwitch.toByteArray(ver, dpData, 0);  //add: ver
		ByteShortSwitch.toByteArray(sType, dpData, 2);  //add: service type
		ByteIntSwitch.toByteArray(assistSessionId, dpData, 4);
		ByteIntSwitch.toByteArray(pingSessionId, dpData, 8);
		dp=new DatagramPacket(dpData,dpData.length);
	}
	public ReversePingMessage1(DatagramPacket dp){
		this.dp=dp;
		dpData=dp.getData();
		ver=ByteShortSwitch.toShort(dpData, 0);
		sType=ByteShortSwitch.toShort(dpData, 2);
		assistSessionId=ByteIntSwitch.toInt(dpData, 4);
		pingSessionId=ByteIntSwitch.toInt(dpData, 8);
	}

	public int getPingSessionId(){
		return pingSessionId;
	}
	
	public int getAssistSessionId(){
		return assistSessionId;
	}

}
